
//
//  HomeView.m
//  MZJ
//
//  Created by XDD on 16/6/3.
//  Copyright © 2016年 XDD. All rights reserved.
//

#import "HomeView.h"

@interface HomeView () <UIScrollViewDelegate> {
    
    NSTimer *timer_;
    BOOL isFromStart_;
    UIPageControl *pageControl_;
}

@property (nonatomic, strong) UIScrollView *carousel_ScrollView;

@end

@implementation HomeView

- (instancetype)initWithFrame:(CGRect)frame {
    
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initializeView];
    }
    return self;
}

- (void)initializeView {
    
    CGFloat size = 0.0;
    if (kHeight == 480) {
        size = 11.0;
    }
    if (kHeight == 568) {
        size = 12.0;
    }
    if (kHeight == 667) {
        size = 13.0;
    }
    if (kHeight == 736) {
        size = 14.0;
    }
    
    self.backgroundColor = [UIColor whiteColor];
    
//    UIImageView *headImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 0, 320, 150), NO)];
//    headImageView.backgroundColor = [UIColor orangeColor];
//    [self addSubview:headImageView];
    
//    _person_head_ImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(132, 35, 56, 56), YES)];
//    _person_head_ImageView.backgroundColor = [UIColor purpleColor];
//    _person_head_ImageView.layer.cornerRadius = 28.0*XJVerticalMultiplier();
//    _person_head_ImageView.layer.masksToBounds = YES;
//    [headImageView addSubview:_person_head_ImageView];
    
//    _nameLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(20, 95, 280, 20), NO)];
//    _nameLabel.text = @"民政局APP";
////    nameLabel.backgroundColor = [UIColor blackColor];
//    _nameLabel.textColor = [UIColor blackColor];
//    _nameLabel.textAlignment = NSTextAlignmentCenter;
//    _nameLabel.font = [UIFont systemFontOfSize:size];
//    [headImageView addSubview:_nameLabel];
    
//    UIButton *person_Data_Btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    person_Data_Btn.frame = XJFlexibleFrame(CGRectMake(5, 20, 310, 90), NO);
//    person_Data_Btn.backgroundColor = [UIColor clearColor];
//    [person_Data_Btn addTarget:self action:@selector(personDataBtnAction) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:person_Data_Btn];
    
//    UIView *pagesView = [[UIView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 120, 320, 30), NO)];
//    pagesView.backgroundColor = [UIColor blackColor];
//    pagesView.alpha = 0.4;
//    [headImageView addSubview:pagesView];
    
//    UIView *line1 = [[UIView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(100, 7, 1, 16), NO)];
//    line1.backgroundColor = [UIColor whiteColor];
//    [pagesView addSubview:line1];
    
//    UIView *line2 = [[UIView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(220, 7, 1, 16), NO)];
//    line2.backgroundColor = [UIColor whiteColor];
//    [pagesView addSubview:line2];
    
//    UIButton *loveBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    loveBtn.frame = XJFlexibleFrame(CGRectMake(10, 120, 80, 30), NO);
//    loveBtn.backgroundColor = [UIColor clearColor];
//    [loveBtn addTarget:self action:@selector(loveBtnAction) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:loveBtn];
    
//    UILabel *label1 = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 1, 80, 14), NO)];
//    label1.text = @"爱心捐赠(次)";
//    label1.backgroundColor = [UIColor blackColor];
//    label1.textColor = [UIColor whiteColor];
//    label1.textAlignment = NSTextAlignmentCenter;
//    label1.font = [UIFont systemFontOfSize:size];
//    [loveBtn addSubview:label1];
    
//    _loveLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 15, 80, 14), NO)];
//    _loveLabel.text = @"12次";
//    _loveLabel.textColor = [UIColor whiteColor];
//    _loveLabel.textAlignment = NSTextAlignmentCenter;
//    _loveLabel.font = [UIFont systemFontOfSize:size];
//    [loveBtn addSubview:_loveLabel];
    
//    UIButton *moneyBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    moneyBtn.frame = XJFlexibleFrame(CGRectMake(110, 120, 100, 30), NO);
//    moneyBtn.backgroundColor = [UIColor clearColor];
//    [moneyBtn addTarget:self action:@selector(moneyBtnAction) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:moneyBtn];
    
//    UILabel *label2 = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 1, 100, 14), NO)];
//    label2.text = @"累积金额(元)";
//    label2.textColor = [UIColor whiteColor];
//    label2.textAlignment = NSTextAlignmentCenter;
//    label2.font = [UIFont systemFontOfSize:size];
//    [moneyBtn addSubview:label2];
    
//    _moneyLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 15, 100, 14), NO)];
//    _moneyLabel.text = @"288.00元";
//    _moneyLabel.textColor = [UIColor whiteColor];
//    _moneyLabel.textAlignment = NSTextAlignmentCenter;
//    _moneyLabel.font = [UIFont systemFontOfSize:size];
//    [moneyBtn addSubview:_moneyLabel];
    
//    UIButton *activeBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
//    activeBtn.frame = XJFlexibleFrame(CGRectMake(230, 120, 80, 30), NO);
//    activeBtn.backgroundColor = [UIColor clearColor];
//    [activeBtn addTarget:self action:@selector(activeBtnAction) forControlEvents:UIControlEventTouchUpInside];
//    [self addSubview:activeBtn];
    
//    UILabel *label3 = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 1, 80, 14), NO)];
//    label3.text = @"志愿者活动(次)";
//    label3.textColor = [UIColor whiteColor];
//    label3.textAlignment = NSTextAlignmentCenter;
//    label3.font = [UIFont systemFontOfSize:size];
//    [activeBtn addSubview:label3];
    
//    _activeLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(0, 15, 80, 14), NO)];
//    _activeLabel.text = @"12次";
//    _activeLabel.textColor = [UIColor whiteColor];
//    _activeLabel.textAlignment = NSTextAlignmentCenter;
//    _activeLabel.font = [UIFont systemFontOfSize:size];
//    [activeBtn addSubview:_activeLabel];

   
    
    UIView *line3 = [[UIView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(160, 150, 1, 285), NO)];
    line3.backgroundColor = [UIColor colorWithRed:241/255.0 green:241/255.0 blue:241/255.0 alpha:1];
    [self addSubview:line3];
    
    UIButton *queryBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    queryBtn.frame = XJFlexibleFrame(CGRectMake(5, 155, 150, 85), NO);
//    queryBtn.backgroundColor = [UIColor greenColor];
    [queryBtn addTarget:self action:@selector(queryBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:queryBtn];
    
    UIImageView *queryImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(54, 15, 42, 36), NO)];
//    queryImageView.backgroundColor = [UIColor orangeColor];
    queryImageView.layer.cornerRadius = 18.0*XJVerticalMultiplier();
    queryImageView.layer.masksToBounds = YES;
    queryImageView.image = [UIImage imageNamed:@"yuanzhu_img@2x"];
    [queryBtn addSubview:queryImageView];
    
    UILabel *queryLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(50, 50, 50, 20), NO)];
    queryLabel.text = @"个案援助";
//    queryLabel.backgroundColor = [UIColor blackColor];
    queryLabel.textColor = [UIColor colorWithRed:76/255.0 green:76/255.0 blue:76/255.0 alpha:1];
    queryLabel.textAlignment = NSTextAlignmentCenter;
    queryLabel.font = [UIFont systemFontOfSize:size];
    [queryBtn addSubview:queryLabel];
    
    UIButton *careBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    careBtn.frame = XJFlexibleFrame(CGRectMake(165, 155, 150, 85), NO);
//    careBtn.backgroundColor = [UIColor greenColor];
    [careBtn addTarget:self action:@selector(careBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:careBtn];
    
    UIImageView *careImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(54, 15, 42, 36), NO)];
//    careImageView.backgroundColor = [UIColor orangeColor];
    careImageView.layer.cornerRadius = 18.0*XJVerticalMultiplier();
    careImageView.layer.masksToBounds = YES;
    careImageView.image = [UIImage imageNamed:@"care_img@2x"];
    [careBtn addSubview:careImageView];
    
    UILabel *careLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(50, 50, 50, 20), NO)];
    careLabel.text = @"关爱活动";
//    careLabel.backgroundColor = [UIColor blackColor];
    careLabel.textColor = [UIColor colorWithRed:76/255.0 green:76/255.0 blue:76/255.0 alpha:1];
    careLabel.textAlignment = NSTextAlignmentCenter;
    careLabel.font = [UIFont systemFontOfSize:size];
    [careBtn addSubview:careLabel];
    
    UIView *line4 = [[UIView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(5, 245, 310, 1), NO)];
    line4.backgroundColor = [UIColor colorWithRed:241/255.0 green:241/255.0 blue:241/255.0 alpha:1];
    [self addSubview:line4];
    
    UIButton *volunteersBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    volunteersBtn.frame = XJFlexibleFrame(CGRectMake(5, 250, 150, 85), NO);
//    volunteersBtn.backgroundColor = [UIColor greenColor];
    [volunteersBtn addTarget:self action:@selector(volunteersBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:volunteersBtn];
    
    UIImageView *volunteersImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(54, 15, 42, 36), NO)];
//    volunteersImageView.backgroundColor = [UIColor orangeColor];
    volunteersImageView.layer.cornerRadius = 18.0*XJVerticalMultiplier();
    volunteersImageView.layer.masksToBounds = YES;
    volunteersImageView.image = [UIImage imageNamed:@"jiuzhu_img@2x"];
    [volunteersBtn addSubview:volunteersImageView];
    
    UILabel *volunteerLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(50, 50, 50, 20), NO)];
    volunteerLabel.text = @"救助项目";
//    volunteerLabel.backgroundColor = [UIColor blackColor];
    volunteerLabel.textColor = [UIColor colorWithRed:76/255.0 green:76/255.0 blue:76/255.0 alpha:1];
    volunteerLabel.textAlignment = NSTextAlignmentCenter;
    volunteerLabel.font = [UIFont systemFontOfSize:size];
    [volunteersBtn addSubview:volunteerLabel];
    
    UIButton *informationBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    informationBtn.frame = XJFlexibleFrame(CGRectMake(165, 250, 150, 85), NO);
//    informationBtn.backgroundColor = [UIColor greenColor];
    [informationBtn addTarget:self action:@selector(informationBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:informationBtn];
    
    UIImageView *informationImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(54, 15, 42, 36), NO)];
//    informationImageView.backgroundColor = [UIColor orangeColor];
    informationImageView.layer.cornerRadius = 18.0*XJVerticalMultiplier();
    informationImageView.layer.masksToBounds = YES;
    informationImageView.image = [UIImage imageNamed:@"wuzi_img@2x"];
    [informationBtn addSubview:informationImageView];
    
    UILabel *informationLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(50, 50, 50, 20), NO)];
    informationLabel.text = @"物资流向";
//    informationLabel.backgroundColor = [UIColor blackColor];
    informationLabel.textColor = [UIColor colorWithRed:76/255.0 green:76/255.0 blue:76/255.0 alpha:1];
    informationLabel.textAlignment = NSTextAlignmentCenter;
    informationLabel.font = [UIFont systemFontOfSize:size];
    [informationBtn addSubview:informationLabel];
    
    UIView *line5 = [[UIView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(5, 340, 310, 1), NO)];
    line5.backgroundColor = [UIColor colorWithRed:241/255.0 green:241/255.0 blue:241/255.0 alpha:1];
    [self addSubview:line5];
    
    UIButton *rescueBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    rescueBtn.frame = XJFlexibleFrame(CGRectMake(5, 345, 150, 85), NO);
//    rescueBtn.backgroundColor = [UIColor greenColor];
    [rescueBtn addTarget:self action:@selector(rescueBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:rescueBtn];
    
    UIImageView *rescueImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(54, 15, 42, 36), NO)];
//    rescueImageView.backgroundColor = [UIColor orangeColor];
    rescueImageView.layer.cornerRadius = 18.0*XJVerticalMultiplier();
    rescueImageView.layer.masksToBounds = YES;
    rescueImageView.image = [UIImage imageNamed:@"zhiyuan_img@2x"];
    [rescueBtn addSubview:rescueImageView];
    
    UILabel *rescueLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(50, 50, 50, 20), NO)];
    rescueLabel.text = @"志愿服务";
//    rescueLabel.backgroundColor = [UIColor blackColor];
    rescueLabel.textColor = [UIColor colorWithRed:76/255.0 green:76/255.0 blue:76/255.0 alpha:1];
    rescueLabel.textAlignment = NSTextAlignmentCenter;
    rescueLabel.font = [UIFont systemFontOfSize:size];
    [rescueBtn addSubview:rescueLabel];
    
    UIButton *helpBtn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    helpBtn.frame = XJFlexibleFrame(CGRectMake(165, 345, 150, 85), NO);
//    helpBtn.backgroundColor = [UIColor greenColor];
    [helpBtn addTarget:self action:@selector(helpBtnAction) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:helpBtn];
    
    UIImageView *helpImageView = [[UIImageView alloc]initWithFrame:XJFlexibleFrame(CGRectMake(54, 15, 42, 36), NO)];
//    helpImageView.backgroundColor = [UIColor orangeColor];
    helpImageView.layer.cornerRadius = 18.0*XJVerticalMultiplier();
    helpImageView.layer.masksToBounds = YES;
    helpImageView.image = [UIImage imageNamed:@"gongyi_img@2x"];
    [helpBtn addSubview:helpImageView];
    
    UILabel *helpLabel = [[UILabel alloc]initWithFrame:XJFlexibleFrame(CGRectMake(50, 50, 50, 20), NO)];
    helpLabel.text = @"公益伙伴";
//    helpLabel.backgroundColor = [UIColor blackColor];
    helpLabel.textColor = [UIColor colorWithRed:76/255.0 green:76/255.0 blue:76/255.0 alpha:1];
    helpLabel.textAlignment = NSTextAlignmentCenter;
    helpLabel.font = [UIFont systemFontOfSize:size];
    [helpBtn addSubview:helpLabel];
}

- (void)loveBtnAction {
//    if (self.didlovebtnButtonBlock) {
//        self.didlovebtnButtonBlock();
//    }
}

- (void)moneyBtnAction {
//    if (self.didmoneybtnButtonBlock) {
//        self.didmoneybtnButtonBlock();
//    }
}

- (void)activeBtnAction {
//    if (self.didactivebtnButtonBlock) {
//        self.didactivebtnButtonBlock();
//    }
}

- (void)queryBtnAction {
    if (self.didqueryBlock) {
        self.didqueryBlock();
    }
}

- (void)careBtnAction {
    if (self.didcareBlock) {
        self.didcareBlock();
    }
}

- (void)volunteersBtnAction {
    if (self.didvolunteersBlock) {
        self.didvolunteersBlock();
    }
}

- (void)informationBtnAction {
    if (self.didinformationBlock) {
        self.didinformationBlock();
    }
}

- (void)rescueBtnAction {
    if (self.didrescueBlock) {
        self.didrescueBlock();
    }
}

- (void)helpBtnAction {
    if (self.didhelpBtnBtnBlock) {
        self.didhelpBtnBtnBlock();
    }
}

//- (void)personDataBtnAction {
//    if (self.didpersonDataBtnBlock) {
//        self.didpersonDataBtnBlock();
//    }
//}

- (void)animationShow {
    
}

@end
